__.BasicModule.register("widget.topnav:topnav_v1.2", "0.0.0", ["widget", "dom", "event", "fn-smartbox", "anim"], function() {
    __.widget.TopNav = function(compName, config) {
        __.widget.Base.call(this);
        this.dom = __.dom.f(compName);//根据ID获得元素方法
        if (!this.dom) {
            return
        }
        this.config = config || {};
        this.config.preFill = this.config.preFill || __.widget.TopNav.defConfig.preFill;
        __.extend(this.config, __.widget.TopNav.defConfig, false);
        this._prepareEls();
        this._loadData()
    }
    ;
    __.inherits(__.widget.TopNav, __.widget.Base);
    __.widget.TopNav.defConfig = {
        useSelf: true,
        autoFocus: true,
        preFill: "\u4ee3\u7801/\u540d\u79f0/\u62fc\u97f3",
        indexNames: ['<a boss="6016" href="http://gu.qq.com/sh000001" title="\u4e0a\u8bc1\u6307\u6570:(000001)" target="_self">\u4e0a\u8bc1\u6307\u6570:</a>', '<a boss="6040" href="http://gu.qq.com/sz399001" title="\u6df1\u8bc1\u6210\u6307:(399001)" target="_self">\u6df1\u8bc1\u6210\u6307:</a>', '<a boss="6015" href="http://gu.qq.com/hkHSI" title="\u6052\u751f\u6307\u6570:(HSI)" target="_self">\u6052\u751f\u6307\u6570:</a>', '<a boss="6038" href="http://gu.qq.com/usDJI" title="\u9053\u743c\u65af:(DJI)" target="_self">\u9053\u743c\u65af:</a>', '<a boss="6039" href="http://gu.qq.com/usIXIC" title="\u7eb3\u65af\u8fbe\u514b:(IXIC)" target="_self">\u7eb3\u65af\u8fbe\u514b:</a>', "\u6cd5\u56fdCAC:", "\u5fb7\u56fdDAX:", "\u65e5\u7ecf225:", "\u6d77\u5ce1\u65f6\u62a5:", "\u53f0\u6e7e\u52a0\u6743\u6307\u6570:", "\u9ec4\u91d1:", "\u77f3\u6cb9:"],
        indexKeys: ["s_sh000001", "s_sz399001", "s_r_hkHSI", "s_usDJI", "s_usIXIC", "gzFCHI", "gzGDAXI", "gzN225", "gzFTSTI", "gzTWII", "fqUS_GC_1", "fqUS_CL_1"],
        indexCfg: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
    };
    __.widget.TopNav.prototype.html = '<span class="first"></span>	<div class="center">		<div  id="top-smartbox-ctn">		<form target="_blank" method="post">			<input type="text" maxlength="11" autocomplete="off" class="nav-smartbox-query fl" name="cl" style="color:#B4B3B3;">			<div class="nav-smartbox-ctn fl">			  <div class="nav-smartbox-cnt-box"></div>			  <input type="hidden" class="nav-smartbox-input" name="qc_type" value="ALL">			</div>			<input type="submit" value="\u80a1\u7968\u67e5\u8be2" name="submitbtn" class="nav-smartbox-submit" boss="6013">			<a href="http://stockapp.finance.qq.com/pstock/" target="_blank" class="istock" boss="6014">\u6211\u7684\u81ea\u9009\u80a1</a>			<span id="div-msg-box-num" boss="6023"></span>			<input type="hidden" name="ZHENGQUANDM">		</form>		</div>	</div>	<span class="cutline"></span>	<div id="stock_box1">		<div title="\u70b9\u51fb\u5411\u4e0a\u6eda\u52a8" id="arr_up" boss="6017"></div>		<div title="\u70b9\u51fb\u5411\u4e0b\u6eda\u52a8" id="arr_do" boss="6018"></div>		<div id="word"></div>	</div>	<span class="last"></span>  ';
    __.widget.TopNav.prototype._prepareEls = function() {
        var g = this;
        this.dom.innerHTML = this.html;
        this.select = new __.widget.Select(__.dom.f(".nav-smartbox-cnt-box"),{
            items: {
                ALL: "\u5168\u90e8",
                GP: "\u6caa\u6df1",
                HK: "\u6e2f\u80a1",
                JJ: "\u57fa\u91d1",
                AS: "\u7f8e\u80a1",
                FT: "\u671f\u8d27"
            },
            defaultValue: "ALL",
            fontsize: 14,
            height: 25,
            width: 59,
            lineHeight: 18,
            borderColor: "transparent",
            bgColor: "transparent",
            bgActive: "-142px -30px",
            bgNormal: "-142px -30px",
            bgSrc: "http://mat1.gtimg.com/finance/png/st/p/hqhk_gg/mainnav_v1.1/sprite-2_v20111121142445.png",
            onChange: function(i) {
                __.dom.f(".nav-smartbox-input").value = i
            }
        });
        __.dom.$(".du-select-ctn div")[1].style.borderWidth = "0";
        this.smartbox = new __.widget.SmartBox("top-smartbox-ctn",{
            useSelf: this.config.useSelf === false ? false : true,
            autoFocus: this.config.autoFocus === false ? false : true,
            preFill: this.config.preFill,
            attach: {
                form: __.dom.f("#top-smartbox-ctn form"),
                type: __.dom.f(".nav-smartbox-input"),
                query: __.dom.f(".nav-smartbox-query"),
                submit: __.dom.f(".nav-smartbox-submit")
            },
            iframeMask: true
        });
        __.dom.f("top-smartbox-ctn-du-sx-result").style.zIndex = 3;
        var h = this.config.indexNames, b = this.config.indexCfg, f = [], e, c;
        for (e = 0; e < b.length; e++) {
            c = b[e];
            f.push((e % 2 === 0) ? "<p>" : "| ", h[c], "<span>--</span><span>--</span><span></span>", (e % 2 === 0) ? "" : "</p>")
        }
        __.dom.f("word").innerHTML = f.join("") + f.join("");
        this.start = this.current = 0;
        this.rows = Math.ceil(b.length / 2);
        this.rowHeight = 29;
        __.event.on("arr_up", "click", function() {
            g.scroll(true)
        });
        __.event.on("arr_do", "click", function() {
            g.scroll(false)
        });
        this.indexSpan = {};
        var d = __.dom.$("span", __.dom.f("word"));
        for (e = 0; e < b.length; e++) {
            c = b[e];
            this.indexSpan[this.config.indexKeys[c]] = [[d[e * 3], d[e * 3 + 1], d[e * 3 + 2]], [d[e * 3 + 6 * this.rows], d[e * 3 + 1 + 6 * this.rows], d[e * 3 + 2 + 6 * this.rows]]]
        }
    }
    ;
    __.widget.TopNav.prototype._loadData = function() {
        var b = this;
        __.widget.TopNav.loadMsgNum(function(c) {
            b._setMsgData(c)
        });
        b._loadIndex()
    }
    ;
    __.widget.TopNav.prototype._loadIndex = function() {
        var b = this;
        if (b._loadIndexTimer) {
            clearTimeout(b._loadIndexTimer);
            b._loadIndexTimer = null 
        }
        if (!b._indexQtKey) {
            b._indexQtKey = b.config.indexKeys.join(",")
        }
        b._indexQtKeyPre = b._indexQtKey;
        __.fnTable.load(b._indexQtKey, function() {
            var c = {};
            __.each(b._indexQtKey.split(","), function(d) {
                if (__.global["v_" + d]) {
                    c[d] = __.global["v_" + d].split("~")
                }
            });
            b._fillIndex(c)
        });
        b._loadIndexTimer = setTimeout(function() {
            b._loadIndex()
        }, 5000)
    }
    ;
    var a = [/^(t_)?s_((sh)|(sz)|((r_)?hk)|(us))/, /^gz/, /^s_((sh)|(sz)|((r_)?hk))/];
    __.widget.TopNav.prototype._fillIndex = function(h) {
        var g = this, f, e = ["--", "--", ""], b = __.fnTable.process, c = __.fnTable.processors, d;
        __.each(h, function(i, j) {
            e = ["--", "--", ""];
            f = g.indexSpan[j];
            if (a[0].test(j)) {
                e[0] = b("S_PRICE", i);
                e[1] = b("S_PERCENT", i)
            } else {
                if (a[1].test(j)) {
                    e[0] = b("S_PRICE", i);
                    e[1] = b("S_PERCENT", i)
                } else {
                    e[0] = b(function(k) {
                        return c.GET_COLOR(k[5].replace(/[,+]/g, ""), k[6].replace(/[,+]/g, ""))
                    }, i);
                    e[1] = b(function(k) {
                        var l = k[6].replace(/[,+]/g, "") * 100 / (k[5].replace(/[,+]/g, "") - k[6].replace(/[,+]/g, ""));
                        return c.GET_COLOR(l.toFixed(2) + "%", k[6].replace(/[,+]/g, ""))
                    }, i)
                }
            }
            if (a[2].test(j)) {
                e[2] = (i["7"] / 10000).toFixed(0) + (j.substr(0, 6) == "s_r_hk" ? "\u4ebf\u6e2f\u5143" : "\u4ebf\u5143")
            }
            for (d = 0; d < 3; d++) {
                f[0][d].innerHTML = e[d];
                f[1][d].innerHTML = e[d]
            }
        }, true);
        g._indexQtKey = g.config.indexKeys[g.config.indexCfg[g.current * 2]] + "," + g.config.indexKeys[g.config.indexCfg[g.current * 2 + 1]]
    }
    ;
    __.widget.TopNav.prototype._setMsgData = function(g) {
        var f = function(h) {
            return h > 99 ? 99 : h
        }
        ;
        var c = __.dom.f("div-msg-box-num");
        if (!c) {
            return
        }
        var e = this;
        if (g && g.data && g.data.total_num) {
            c.innerHTML = ['<div style="position:relative;width:52px;height:20px;line-height:20px;z-index:2;">', " <span>", '   <a target="_blank" style="width:52px;display:block;cursor:pointer;" href="http://stockapp.finance.qq.com/pstock/msgbox.php">', '   <span style="background:url(http://mat1.gtimg.com/finance/images/stock/p/hqhk_gg/mainnav_v1.1/icon.png) no-repeat;width:14px;height:13px;float:left;margin:3px 2px;"></span>', '   <span style="float:left;color:#d70300">(<span style="font-weight:bold;">', f(g.data.total_num[1]), "</span>)</span>", "   </a>", " </span>", ' <div style="text-align:left;width:177px;line-height:18px;border:1px solid #FDD66F;background-color:#FFF8C1;padding: 3px 10px; z-index:3;position:absolute;top:20px;left:20px;display:none;"></div>', "</div>"].join("");
            var b = c.getElementsByTagName("a")[0]
              , d = c.getElementsByTagName("div")[1];
            if (g.data.total_num[1] <= 0) {
                d.innerHTML = "\u6682\u65e0\u672a\u8bfb\u6d88\u606f\uff0c\u70b9\u51fb\u67e5\u770b\u5386\u53f2\u6d88\u606f";
                d.style.width = "180px"
            } else {
                d.innerHTML = ["\u80a1\u4ef7\u6d88\u606f(", f(g.data.stock_num[1]), ")<br>", "\u8d44\u8baf\u6d88\u606f(", f(g.data.info_num[1]), ")<br>", "\u51c0\u503c\u6d88\u606f(", f(g.data.fund_num[1]), ")<br>", "\u7279\u8272\u6d88\u606f(", f(g.data.special_num[1]), ")<br>"].join("");
                d.style.width = "72px"
            }
            b.onmouseover = function() {
                d.style.display = "block"
            }
            ;
            b.onmouseout = function() {
                d.style.display = "none"
            }
            ;
            b.onclick = function() {
                setTimeout(function() {
                    g.data.total_num[1] = 0;
                    e._setMsgData(g)
                }, 100)
            }
        } else {
            c.innerHTML = ""
        }
    }
    ;
    __.widget.TopNav.loadMsgNum = function(c) {
        var b = document.cookie.match(/l?uin=o(\d+)/)
          , d = this;
        b = b && b[1];
        if (b) {
            b = b.replace(/^0*/, "");
            __.set("__.app.Stockdiy.data.mbox");
            __.load("http://message.finance.qq.com/tips/get_msg_num.php?uid=" + b + "&name=pstock", function() {
                if (typeof c == "function") {
                    c(__.app.Stockdiy.data.mbox.msgnum)
                }
            })
        } else {
            if (typeof c == "function") {
                c(false)
            }
        }
    }
    ;
    __.widget.TopNav.prototype.scroll = function(e) {
        var d, b, c = this;
        if (this._isrunning) {
            return
        }
        if (c._indexQtKeyPre.split(",").length < c.config.indexKeys.length) {
            c._indexQtKey = "";
            c._loadIndex()
        } else {
            c._indexQtKey = ""
        }
        e = !!e;
        b = __.dom.f("word");
        if (e) {
            if (this.current < 0) {
                this.current = this.rows;
                b.scrollTop = this.rowHeight * this.current
            }
            this.current--
        } else {
            if (this.current > this.rows) {
                this.current = 0;
                b.scrollTop = 0
            }
            this.current++
        }
        d = new __.Anim(b,"scrollTop",{
            to: b.scrollTop + (e ? -this.rowHeight : this.rowHeight),
            isStyle: false,
            onOver: function() {
                c._isrunning = false
            }
        });
        c._isrunning = true;
        d.run()
    }
    ;
    __.widget.TopNav.prototype.disposeInternal = function() {
        __.widget.TopNav._super.disposeInternal.call(this);
        this.select.dispose();
        this.smartbox.dispose();
        if (this._loadIndexTimer) {
            clearTimeout(this._loadIndexTimer)
        }
        if (this.dom) {
            this.dom.innerHTML = ""
        }
        this.select = this.smartbox = this._loadIndexTimer = this.dom = null 
    }
});
/*  |xGv00|a6cc9964e02688b5e5fc78cc59c19258 */